require "rubygems"
require "test/unit"
#
##
#
class TestMeepMeep < Test::Unit::TestCase
  #
  # to specify path to the application under test explicitely
  # return the full path to the script file
  def self.get_aut_path
    return "#{File.expand_path( File.dirname( __FILE__ ) )}/meepmeep.rb"
  end
  #
  #
  def test_neg_raise_on_wrong_argument
    assert_raise( RuntimeError ) {
      `ruby #{TestMeepMeep.get_aut_path}`
      raise RuntimeError if not $?.success?
    }
  end
  #
  #
  def test_pos_noraise_on_good_argument
    assert_nothing_raised() {
      `ruby #{TestMeepMeep.get_aut_path} /path/to/a/file`
      raise RuntimeError if not $?.success?
    }
  end
  #
  #
  def test_pos_can_run_as_script
    assert_nothing_raised() {
      `#{TestMeepMeep.get_aut_path} /path/to/a/file`
      raise RuntimeError if not $?.success?
    }
  end
  #
  #
  def test_neg_newline_after_string
    meepmeep_output = `ruby #{TestMeepMeep.get_aut_path} /path/to/a/file`
    assert_equal("Meep meep!\n", meepmeep_output, message = "The out put should be followed by a single newline!")
  end
end